<include file="Public/min-header" />
<script type="text/javascript">
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$URL_upload}";
    var URL_fileUp = "{$URL_fileUp}";
    var URL_scrawlUp = "{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$URL_getRemoteImage}";
    var URL_imageManager = "{$URL_imageManager}";
    var URL_imageUp = "{$URL_imageUp}";
    var URL_getMovie = "{$URL_getMovie}";
    var URL_home = "{$URL_home}";
</script>
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.config.js" />
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.all.js" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="__ROOT__/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title"><if condition="$act eq 'add'">增加<else />编辑</if>满减活动</h3>
                        <a href="{:U('Article/articleList')}" data-toggle="tooltip" title="" class="btn btn-primary pull-right" data-original-title="返回"><i class="fa fa-reply"></i></a>
                    </div>
                    <form class="form-horizontal" action="{:U('Promotion/f_detail')}" id="add_post"  method="post">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">活动标题</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" value="{$info.title}" name="title">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">活动条件</label>
                                <div class="col-sm-1" style="line-height:32px;"><input type="text" class="form-control" value="{$info.fill_price}" name="fill_price" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')"></div>
                                <div class="col-sm-1" style="line-height:32px;"><input type="text" class="form-control" value="{$info.use_price}" name="use_price" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')"></div>
                                <div class="col-sm-6" style="line-height:32px;">(满'-'元减'-'元)</div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">活动开始时间</label>
                                <div class="col-sm-8">
                                    <input class="control-label Wdate" name="start_time" type="text" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" <if condition="$info['start_time'] gt 0">value="{$info.start_time|date='Y-m-d H:i:s',###}"</if>>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">活动结束时间</label>
                                <div class="col-sm-8">
                                    <input class="control-label Wdate" name="end_time" type="text" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" <if condition="$info['end_time'] gt 0">value="{$info.end_time|date='Y-m-d H:i:s',###}"</if>>
                                </div>
                            </div>
                            <div class="form-group" style="height:410px;">
                                <label for="text" class="col-sm-2 control-label">参与的商品</label>
                                <div class="col-sm-3">
                                    <div class="left_goods">
                                        <volist name="goods_list" id="val">
                                            <div class="goods{$val.id}" onclick="check_left_goods(this);" data-id="{$val.id}">{$val.goods_name}</div>
                                        </volist>
                                    </div>
                                </div>
                                <div class="col-sm-2 goods_center" style="text-align:center;">
                                    <div onclick="all_check();"><span><< 全选</span></div>
                                    <div onclick="left_check();"><span> >> </span></div>
                                    <div onclick="right_check();"><span> << </span></div>
                                    <div onclick="cancle_check();"><span>全选 >></span></div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="right_goods">
                                        <volist name="right_list" id="val">
                                            <div class="goods{$val.id}" onclick="check_right_goods(this);" data-id="{$val.id}">{$val.goods_name}</div>
                                        </volist>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">是否显示</label>
                                <div class="col-sm-5" style="margin-top:5px;">
                                    <div class="col-sm-2">
                                        <label>
                                            <input type="radio" name="status" value="1" <if condition="$info['status'] eq 1">checked</if>> 显示 </label>
                                    </div>
                                    <div class="col-sm-2">
                                        <label>
                                            <input type="radio" name="status" value="0" <if condition="$info['status'] eq 0">checked</if>> 不显示</label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-sm-2">
                                    <input type="hidden" name="act" value="{$act}">
                                    <input type="hidden" name="id" value="{$info.id}">
                                    <input type="hidden" name="type_id" value="1">
                                </label>
                                <div class="col-sm-8">
                                    <button type="reset" class="btn btn-primary">重置</button>
                                    <button type="button" onclick="checkForm()" class="btn btn-info pull-right">提交</button>
                                </div>
                            </div>
                        </div>
                        <div class="box-footer row">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script src="__ROOT__/Public/Admin/js/date_time/WdatePicker.js"></script>
<script type="text/javascript">
    function checkForm() {
        if ($('input[name="title"]').val() == '') {
            layer.alert('请填写消息标题', {icon: 2 });
            return false;
        }
        window.cont = '';
        $('.right_goods div').each(function(){
            window.cont+=$(this).attr('data-id')+',';
        });
        if(!cont){
            layer.alert('请选择参与活动的商品', {icon: 2 });
            return false;
        }else{
            $('#add_post').append('<input type="hidden" name="goods_list" value="'+cont+'">');
        }
        $('#add_post').submit();
    }
    function check_left_goods(obj){
        if($(obj).hasClass('cur')){
            $(obj).removeClass('cur');
        }else{
            $(obj).addClass('cur');
        }
    }
    function check_right_goods(obj){
        if($(obj).hasClass('cur')){
            $(obj).removeClass('cur');
        }else{
            $(obj).addClass('cur');
        }
    }
    function all_check(){
        $('.left_goods div').addClass('cur');
    }
    function cancle_check(){
        $('.right_goods div').addClass('cur');
    }
    function left_check(){
        window.html = '';
        $('.left_goods div.cur').each(function(){
            window.html+='<div onclick="check_right_goods(this);" data-id="'+$(this).attr('data-id')+'">'+$(this).html()+'</div>';
            $(this).remove();
        });
        if(!html){
            layer.alert('请选择商品', {icon: 2 });
            return false;
        }
        $('.right_goods').append(html);
    }
    function right_check(){
        window.html = '';
        $('.right_goods div.cur').each(function(){
            window.html+='<div onclick="check_left_goods(this);" data-id="'+$(this).attr('data-id')+'">'+$(this).html()+'</div>';
            $(this).remove();
        });
        if(!html){
            layer.alert('请选择商品', {icon: 2 });
            return false;
        }
        $('.left_goods').append(html);
    }
    $(function(){
        laydate({
            elem: '#demo'
        })
    });
</script>
</body>
</html>
